<?php

namespace App\Http\Controllers\Admin;

use App\Common\CommonHelpers;
use App\Models\Menu;
use App\Traits\ModelAttributes;
use Illuminate\Http\Request;

use App\Http\Controllers\Controller;
use App\Repositories\PermissionRepository;
use Illuminate\Support\Facades\Validator;

class PermissionsController extends Controller
{
    use ModelAttributes;
    /**
     * @var PermissionRepository
     */
    protected $repository;


    public function __construct(PermissionRepository $repository)
    {

        $this->repository = $repository;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('admin.menu.index');

    }

    public function tree()
    {
        $permissions = $this->repository->recurrence();
        if (request()->wantsJson()) {
            return response()->json([
                'code' => 0,
                'msg' => '',
                'data' => $permissions,
            ]);
        }
        return view('admin.admin.permissions.index');
    }
}
